import json
import random
import time
from urllib import request

import numpy as np
from bs4 import BeautifulSoup

import mysql.connector
from fdfs_client.client import get_tracker_conf, Fdfs_client


def initMysql():
  global mydb
  global mycursor

  # mydb = mysql.connector.connect(
  #   host='8.129.219.66',
  #   user='guifangtong',
  #   passwd='guifangtong1234!@#',
  #   database='guifangtong'
  # )

  mydb = mysql.connector.connect(
    host='localhost',
    user='root',
    passwd='root1234',
    database='guifangtong'
  )

  mycursor = mydb.cursor()


def findFangs():
  initMysql()
  table_name = 't_fang'
  sql = "select * from " + table_name
  mycursor.execute(sql)
  myresult = mycursor.fetchall()  # fetchall() 获取所有记录
  return myresult

def updateFangFacePic(item):
  pass


if __name__ == '__main__':

  resFangs = findFangs()
  for item in resFangs:
    updateFangFacePic(item)
    # time.sleep(2)
